#ifndef _PATH_FOLLOWING_H_
#define _PATH_FOLLOWING_H_

#include "car_road_info_manager.h"
#include <Common\Base\hkBase.h>
#include <Common\Base\Math\Vector\hkVector2.h>
#include "Singleton.hpp"


class PathPoint
{
public:
	PathPoint(void);
	virtual ~PathPoint(void);

public:
	typedef boost::shared_ptr<car_road_info_manager>& path_point_type;

public:
	struct Parms
	{
		Parms(void);

		const hkVector2* VehiclePosition;
		const hkVector2* VehicleForward;
		float VehicleSpeed;
		float MinFeelerLength;
		float FeelerGainFactor;
		bool IsInverseGetPoint;
	};

	struct Info
	{
		Info(void);

		hkVector2 PointFollowing;
		hkVector2 RoadDirection;
		bool IsPathPointOver;
	};

public:
	const Info& get_point(path_point_type roadPoints, int id, const Parms& parms);

private:
	void get_apeak_point(const hkVector2& fromPos, const hkVector2& toPos, const hkVector2& checkPos, hkVector2& result) const;
	bool get_point_following(path_point_type roadPoints, int id, const Parms& parms);
	void generate_road_direction(path_point_type roadPoints, int id, const Parms& parms);
	void check_valide(const Parms& parms) const;
	void get_feeler(const Parms& parms, hkVector2& feeler);
	void save_parms(path_point_type roadPoints, int id, const Parms& parms);
	void save_current_to_following(path_point_type roadPoints, int id);
	void get_next_or_prev(path_point_type roadPoints, int id, const Parms& parms);

private:
	Info m_info;
	hkVector2 m_currentPoint;
	hkVector2 m_otherPoint;
	hkVector2 m_apeakPoint;
	hkVector2 m_feelerPosition;
	hkVector2 m_inverseForward;
};



#endif